package org.cornland.systemWarning.common.exception;

import lombok.extern.slf4j.Slf4j;
import org.cornland.systemWarning.model.RespBean;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理所有不可知的异常
     */
    @ExceptionHandler(Exception.class)
    public RespBean handleException(Exception e){
        // 打印堆栈信息
        log.error(e.getMessage(), e);
        return RespBean.error(e.getMessage());
    }
}
